from django.shortcuts import redirect
from django.utils.deprecation import MiddlewareMixin


class Session(MiddlewareMixin):
    while_list = ['/admins/login/', ]

    def process_request(self, request):
        path = request.path
        if path not in self.while_list:
            ret = request.session.get('is_login')
            if not ret:
                return redirect('/admins/login/')
